#pragma once

#include <flash/flash.h>


#define PT_STR_GBIOS    "g-bios"
#define PT_STR_LINUX    "linux"
#define PT_STR_WINCE    "wince"
#define PT_STR_RAMDISK  "ramdisk"
#define PT_STR_CRAMFS   "cramfs"
#define PT_STR_JFFS2    "jffs2"
#define PT_STR_YAFFS    "yaffs"
#define PT_STR_YAFFS2   "yaffs2"
#define PT_STR_FREE     "free"

#define PT_MAX (PT_FREE + 1)


struct PartInfo
{
	int nParts;
	struct PartAttr vAttrTab[MAX_FLASH_PARTS];
};


//////////////////
struct Partition *GuPartOpen(int nPartIndex);

int GuPartClose(struct Partition *pPart);

long GuPartRead(struct Partition *, void *, ULONG);

long GuPartWrite(struct Partition *, const void *, ULONG);

struct Partition *GuPartOpenCur(void);

int GuPartChange(int nPartIndex);

int GuPartTabRead(const struct Flash *pHost, struct PartAttr pPartAttr[], int nPartNum);

const char *GuPartTypeToStr(UINT32 nType);

const char *GuPartGetName(const struct PartAttr *pPart);

int GuPartGetIndex(const struct Partition *pPart);

static __INLINE__ int GuPartGetAttr(const struct Partition *pPart, struct PartAttr *pAttr)
{
	*pAttr = *pPart->pAttr;

	return 0;
}

static __INLINE__ int GuPartGetType(const struct Partition *pPart)
{
	BUG_IF(NULL == pPart || NULL == pPart->pAttr)

	return pPart->pAttr->nPartType;
}

static __INLINE__ int GuPartGetBase(struct Partition *pPart)
{
	return pPart->pAttr->ulPartBase;
}

static __INLINE__ int GuPartGetSize(struct Partition *pPart)
{
	return pPart->pAttr->ulPartSize;
}

int GuPartGetImgInfo(const struct Partition *pPart, char szImgName[], ULONG *pulSize);

int GuPartSetImgInfo(struct Partition *pPart, char szImgName[], ULONG ulSize);

